<template>
  <div>
    <el-button @click="resetDateFilter">清除日期过滤器</el-button>
  <el-button @click="clearFilter">清除所有过滤器</el-button>
  <el-table
    ref="filterTable"
    :data="tData"
    style="width: 100%">
    <el-table-column
      prop="time"
      label="日期"
      sortable
      width="380"
    >
    </el-table-column>
    <el-table-column
      prop="order"
      label="订单号"
      width="380">
    </el-table-column>
    <el-table-column
      prop="value"
      label="总价"
      width="380">
    </el-table-column>
  </el-table>
  </div>
</template>

<script>
import axios from 'axios';
  export default {
    data() {
      return {
        tableData: [{
          date: '2016-05-02',
          name: '肯德基',
          price: '26',
          address: '上海市普陀区金沙江路 1518 弄',
          tag: '家'
        }, {
          date: '2016-05-04',
          name: '麦当劳',
          price: '26',
          address: '上海市普陀区金沙江路 1517 弄',
          tag: '公司'
        }, {
          date: '2016-05-01',
          name: '德克士',
          price: '26',
          address: '上海市普陀区金沙江路 1519 弄',
          tag: '家'
        }, {
          date: '2016-05-03',
          name: '华莱士',
          price: '26',
          address: '上海市普陀区金沙江路 1516 弄',
          tag: '公司'
        }],
        tData: []
      }
    },
    created() {
          this.getAllOrders();
      },
    methods: {
      resetDateFilter() {
        this.$refs.filterTable.clearFilter('date');
      },
      clearFilter() {
        this.$refs.filterTable.clearFilter();
      },
      formatter(row, column) {
        return row.address;
      },
      filterTag(value, row) {
        return row.tag === value;
      },
      filterHandler(value, row, column) {
        const property = column['property'];
        return row[property] === value;
      },
      async getAllOrders() {
          axios.post(`/customer/allorder`,{
        })
        .then((res) => { 
          this.tData = res.data;
          console.log("post data")
          console.log(this.tData)
        })
        }
    }
  }
</script>